<template>
  <div class="custom-form">
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px" :key="showFormKey">
        <!-- 耗材合同审批 -->
        <el-col :span="24">
          <el-form-item label-width="0" prop="field10049e8">
            <h2 align='center' style="color:undefined;font-size: nullpx;text-align: center">耗材合同审批</h2>
          </el-form-item>
        </el-col>
        <!-- 当前用户 -->
        <el-col :span="24" v-if="hasFormPermission('current_user_id')" v-show="showFlag">
          <el-form-item :label="$t('当前用户')" prop="current_user_id">
            <avue-information-body :operationVal="operationVal" infoType='user' :whetherToRebindSecondaryEditing='false'
              v-model="formData['current_user_id']" placeholder="当前用户"
              :disabled="hasDisabledPermission('current_user_id', true)"
              :readonly="!hasEditPermission('current_user_id', true)" :style="{ width: '100%' }">
            </avue-information-body>
          </el-form-item>
        </el-col>
        <!-- 职级名称 -->
        <el-col :span="24" v-if="hasFormPermission('job')" v-show="showFlag">
          <el-form-item :label="$t('职级名称')" prop="job">
            <el-input v-model="formData['job']" placeholder="请输入职级名称" :disabled="hasDisabledPermission('job', false)"
              :readonly="!hasEditPermission('job', false)" clearable :style="{ width: '100%' }"></el-input>
          </el-form-item>
        </el-col>
        <!-- 角色ID -->
        <el-col :span="24" v-if="hasFormPermission('role_id')" v-show="showFlag">
          <el-form-item :label="$t('角色ID')" prop="role_id">
            <el-input v-model="formData['role_id']" placeholder="请输入角色ID"
              :disabled="hasDisabledPermission('role_id', false)" :readonly="!hasEditPermission('role_id', false)"
              clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 角色名称 -->
        <el-col :span="24" v-if="hasFormPermission('role_name')" v-show="showFlag">
          <el-form-item :label="$t('角色名称')" prop="role_name">
            <el-input v-model="formData['role_name']" placeholder="请输入角色名称"
              :disabled="hasDisabledPermission('role_name', false)" :readonly="!hasEditPermission('role_name', false)"
              clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 地区 -->
        <el-col :span="24" v-if="hasFormPermission('area')" v-show="showFlag">
          <el-form-item :label="$t('地区')" prop="area">
            <el-input v-model="formData['area']" placeholder="请输入地区" :disabled="hasDisabledPermission('area', false)"
              :readonly="!hasEditPermission('area', false)" clearable :style="{ width: '100%' }"></el-input>
          </el-form-item>
        </el-col>
        <!-- 申请人ID -->
        <el-col :span="24" v-if="hasFormPermission('user_id')" v-show="showFlag">
          <el-form-item :label="$t('申请人ID')" prop="user_id">
            <el-input v-model="formData['user_id']" placeholder="请输入申请人ID"
              :disabled="hasDisabledPermission('user_id', false)" :readonly="!hasEditPermission('user_id', false)"
              clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 申请时间 -->
        <el-col :span="24" v-if="hasFormPermission('apply_time')" v-show="showFlag">
          <el-form-item :label="$t('申请时间')" prop="apply_time">
            <el-input v-model="formData['apply_time']" placeholder="请输入申请时间"
              :disabled="hasDisabledPermission('apply_time', false)" :readonly="!hasEditPermission('apply_time', false)"
              clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 申请人名称 -->
        <el-col :span="24" v-if="hasFormPermission('user_name')">
          <el-form-item :label="$t('申请人名称')" prop="user_name">
            <el-input v-model="formData['user_name']" placeholder="请输入申请人名称"
              :disabled="hasDisabledPermission('user_name', false)" :readonly="!hasEditPermission('user_name', false)"
              clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 部门简称 -->
        <el-col :span="24" v-if="hasFormPermission('depart_short_name')" v-show="showFlag">
          <el-form-item :label="$t('部门简称')" prop="depart_short_name">
            <el-input v-model="formData['depart_short_name']" placeholder="请输入部门简称"
              :disabled="hasDisabledPermission('depart_short_name', false)"
              :readonly="!hasEditPermission('depart_short_name', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 部门 -->
        <el-col :span="24" v-if="hasFormPermission('depart_id')">
          <el-form-item :label="$t('部门')" prop="depart_id">
            <el-select v-model="formData['depart_id']" placeholder="请选择部门"
              :disabled="hasDisabledPermission('depart_id', false)" @change="departmentChange" filterable clearable
              :style="{ width: '100%' }">
              <el-option v-for="(item, index) in departmentData" :key="index" :label="item.F_FullName"
                :value="item.F_DepartmentId" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- 是否生效 -->
        <el-col :span="24" v-if="hasFormPermission('is_effective')" v-show="showFlag">
          <el-form-item :label="$t('是否生效')" prop="is_effective">
            <el-input v-model="formData['is_effective']" placeholder="请输入是否生效"
              :disabled="hasDisabledPermission('is_effective', false)"
              :readonly="!hasEditPermission('is_effective', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 合同金额 -->
        <el-col :span="24" v-if="hasFormPermission('conctract_money')">
          <el-form-item :label="$t('合同金额')" prop="conctract_money">
            <el-input v-model="formData['conctract_money']" type="number" placeholder="请输入合同金额"
              :disabled="hasDisabledPermission('conctract_money', false)"
              :readonly="!hasEditPermission('conctract_money', false)" clearable :style="{ width: '100%' }">
              <template slot="append">元</template>
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 大写 -->
        <el-col :span="24">
          <el-form-item :label="$t('大写')" v-show="formData['conctract_money'] > 0">
            <div style="color:#0063f5;">{{ convertCurrency(formData['conctract_money']) }}</div>
          </el-form-item>
        </el-col>
        <!-- 付款方式 -->
        <el-col :span="24" v-if="hasFormPermission('pay_type')">
          <el-form-item :label="$t('付款方式')" prop="pay_type">
            <el-select v-model="formData['pay_type']" placeholder="请选择付款方式"
              :disabled="hasDisabledPermission('pay_type', false)" @change="selectPayType" filterable clearable
              :style="{ width: '100%' }">
              <el-option v-for="(item, index) in pay_typeOptions" :key="index" :label="item.F_ItemName"
                :value="item.F_ItemValue" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- 其他付款比例说明 -->
        <el-col :span="24" v-if="hasFormPermission('other_pay_percert_desc')" v-show="payTypeDesc">
          <el-form-item :label="$t('其他付款比例说明')" prop="other_pay_percert_desc">
            <el-input v-model="formData['other_pay_percert_desc']" placeholder="请输入其他付款比例说明"
              :disabled="hasDisabledPermission('other_pay_percert_desc', false)"
              :readonly="!hasEditPermission('other_pay_percert_desc', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        
        <!-- 采购需求清单 -->
        <el-col :span="24" v-if="hasFormPermission('material_need_list')">
          <el-form-item :label="$t('采购需求清单')" prop="material_need_list">
            <el-input v-model="formData['material_need_list']" placeholder="请输入耗材采购需求清单"
              :disabled="hasDisabledPermission('material_need_list', false)" @focus="selectApprovalForm"
              :readonly="!hasEditPermission('material_need_list', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 关联审批单 -->
        <el-col :span="24" v-show="selectData.length > 0">
          <el-form-item label="">
            <div class="del_items" v-for="(item,index) in selectData" :key="index">
              <div class="del-items-left"><img src="../../../assets/card/file.png"></div>
              <div class="del-items-middle">{{item.startUser}}提交的{{item.schemeName}}</div>
              <div class="del-items-refuse" v-if="item.status==0">审批拒绝</div>
              <div class="del-items-adopt" v-else-if="item.status==1">审批通过</div>
              <div class="del-items-processing" v-else>审批中</div>
              <div class="del-items-close" @click="delApproval(item,index)"><img src="../../../assets/card/close.png"></div>
            </div>
          </el-form-item>
        </el-col>
        
        <!-- 耗材合同审批部门 -->
        <el-col :span="24" v-if="hasFormPermission('mateial_contract_depart_id')">
          <el-form-item :label="$t('耗材合同审批部门')" prop="mateial_contract_depart_id">
            <!-- <avue-input-tree v-model="formData['mateial_contract_depart_id']"
              :disabled="hasDisabledPermission('mateial_contract_depart_id', false)" placeholder="系统默认(公司)耗材合同审批部门"
              type="tree" :dic="mateial_contract_depart_idOptions" :style="{ width: '100%' }"></avue-input-tree> -->
              <SelectDepartment @sendData="sendDepartData"/>
          </el-form-item>
        </el-col>
        <!-- 适用范围 -->
        <el-col :span="24" v-if="hasFormPermission('use_scope')">
          <el-form-item :label="$t('适用范围')" prop="use_scope">
            <el-select v-model="formData['use_scope']" placeholder="请选择适用范围"
              :disabled="hasDisabledPermission('use_scope', false)" filterable clearable :style="{ width: '100%' }">
              <el-option v-for="(item, index) in use_scopeOptions" :key="index" :label="item.F_ItemName"
                :value="item.F_ItemValue" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- 合同名称 -->
        <el-col :span="24" v-if="hasFormPermission('contract_name')">
          <el-form-item :label="$t('合同名称')" prop="contract_name">
            <el-input v-model="formData['contract_name']" placeholder="请输入合同名称"
              :disabled="hasDisabledPermission('contract_name', false)"
              :readonly="!hasEditPermission('contract_name', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 合同主体 -->
        <el-col :span="24" v-if="hasFormPermission('contract_obj')">
          <el-form-item :label="$t('合同主体')" prop="contract_obj">
            <el-select v-model="formData['contract_obj']" placeholder="请选择合同主体" @change="selectContractObj"
              :disabled="hasDisabledPermission('contract_obj', false)" filterable clearable :style="{ width: '100%' }">
              <el-option v-for="(item, index) in contract_objOptions" :key="index" :label="item.F_ItemName"
                :value="item.F_ItemValue" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- 其他合同主体说明 -->
        <el-col :span="24" v-if="hasFormPermission('other_contract_desc')" v-show="otherContractDesc">
          <el-form-item :label="$t('其他合同主体说明')" prop="other_contract_desc">
            <el-input v-model="formData['other_contract_desc']" placeholder="请输入其他合同主体说明"
              :disabled="hasDisabledPermission('other_contract_desc', false)"
              :readonly="!hasEditPermission('other_contract_desc', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 合同编号 -->
        <el-col :span="24" v-if="hasFormPermission('contract_num')">
          <el-form-item :label="$t('合同编号')" prop="contract_num">
            <el-input v-model="formData['contract_num']" placeholder="请输入合同编号"
              :disabled="hasDisabledPermission('contract_num', false)"
              :readonly="!hasEditPermission('contract_num', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 产品名称 -->
        <el-col :span="24" v-if="hasFormPermission('product_name')">
          <el-form-item :label="$t('产品名称')" prop="product_name">
            <el-input v-model="formData['product_name']" placeholder="请输入产品名称"
              :disabled="hasDisabledPermission('product_name', false)"
              :readonly="!hasEditPermission('product_name', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 产品数量 -->
        <el-col :span="24" v-if="hasFormPermission('product_count')">
          <el-form-item :label="$t('产品数量')" prop="product_count">
            <el-input v-model="formData['product_count']" placeholder="请输入产品数量"
              :disabled="hasDisabledPermission('product_count', false)"
              :readonly="!hasEditPermission('product_count', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 产品型号 -->
        <el-col :span="24" v-if="hasFormPermission('product_type')">
          <el-form-item :label="$t('产品型号')" prop="product_type">
            <el-input v-model="formData['product_type']" placeholder="请输入产品型号"
              :disabled="hasDisabledPermission('product_type', false)"
              :readonly="!hasEditPermission('product_type', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 签订日期 -->
        <el-col :span="24" v-if="hasFormPermission('agreement_date')">
          <el-form-item :label="$t('签订日期')" prop="agreement_date">
            <el-date-picker :disabled="hasDisabledPermission('agreement_date', false)"
              :readonly="!hasEditPermission('agreement_date', false)" v-model="formData['agreement_date']"
              format="yyyy-MM-dd" value-format="yyyy-MM-dd" :style="{ width: '100%' }" placeholder="请选择签订日期" clearable>
            </el-date-picker>
          </el-form-item>
        </el-col>
        <!-- 交期时间 -->
        <el-col :span="24" v-if="hasFormPermission('devlier_date')">
          <el-form-item :label="$t('交期时间')" prop="devlier_date">
            <el-input v-model="formData['devlier_date']" placeholder="请输入交期时间"
              :disabled="hasDisabledPermission('devlier_date', false)"
              :readonly="!hasEditPermission('devlier_date', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 对方名称 -->
        <el-col :span="24" v-if="hasFormPermission('taunts_name')">
          <el-form-item :label="$t('对方名称')" prop="taunts_name">
            <el-input v-model="formData['taunts_name']" placeholder="请输入对方名称"
              :disabled="hasDisabledPermission('taunts_name', false)"
              :readonly="!hasEditPermission('taunts_name', false)" clearable :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-col>
        <!-- 对方联系人 -->
        <el-col :span="24" v-if="hasFormPermission('taunts_user_id')">
          <el-form-item :label="$t('对方联系人')" >
            <!-- <el-input v-model="formData['taunts_user_id']" placeholder="请输入对方联系人"
              :disabled="hasDisabledPermission('taunts_user_id', false)"
              :readonly="!hasEditPermission('taunts_user_id', false)" clearable :style="{ width: '100%' }">
            </el-input> -->
            <div class="table">
              <div class="table-header">
                <div class="table-header-name itemsss">姓名</div>
                <div class="table-header-phone itemsss">电话</div>
                <div class="table-header-company itemsss">公司</div>
                <div class="table-header-position itemsss">职位</div>
                <div class="table-header-address itemsss">地址</div>
                <div class="table-header-email itemsss">邮箱</div>
                <div class="table-header-remark itemsss">备注</div>
              </div>
              <div class="table-body">
                <div class="table-header-name itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_name" placeholder="请输入姓名"></el-input>
                </div>
                <div class="table-header-phone itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_mobile_num" placeholder="请输入电话">
                  </el-input>
                </div>
                <div class="table-header-company itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_company" placeholder="请输入公司"></el-input>
                </div>
                <div class="table-header-position itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_position" placeholder="请输入职位"></el-input>
                </div>
                <div class="table-header-address itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_address" placeholder="请输入地址"></el-input>
                </div>
                <div class="table-header-email itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_email_address" placeholder="请输入邮箱">
                  </el-input>
                </div>
                <div class="table-header-remark itemsss">
                  <el-input v-model="formData.party_contact_dto.party_contact_remark" placeholder="请输入备注"></el-input>
                </div>
              </div>
            </div>
          </el-form-item>
        </el-col>
        <!-- 特殊条款 -->
        <el-col :span="24" v-if="hasFormPermission('special_item')">
          <el-form-item :label="$t('特殊条款')" prop="special_item">
            <!-- <el-input v-model="formData['special_item']" placeholder="请输入特殊条款"
              :disabled="hasDisabledPermission('special_item', false)"
              :readonly="!hasEditPermission('special_item', false)" clearable :style="{ width: '100%' }">
            </el-input> -->
            <el-link type="primary" @click="addDetails">增加明细</el-link>
            <div class="payment_detail-items" v-for="(item, index) in formData.details" :key="index">
              明细{{ index + 1 }}&nbsp;<span class="visibility">隐藏</span>
              <el-input class="el-input-items" v-model="item.content" placeholder="请输入内容"></el-input>&nbsp;<span
                class="visibility">隐藏</span>
              <el-link type="primary" @click="delDetails(index)">删除</el-link>
            </div>
          </el-form-item>
        </el-col>
        <!-- 合同扫描件/word/pdf -->
        <el-col :span="24" v-if="hasFormPermission('scan_file_url')">
          <el-form-item :label="$t('合同扫描件/word/pdf')" prop="scan_file_url">
            <xjr-custom-upload :config="scan_file_urlConfig" :disabled="hasDisabledPermission('scan_file_url', false)"
              v-model="formData['scan_file_url']" list-type="text"></xjr-custom-upload>
          </el-form-item>
        </el-col>
        <!-- 合同附件/保密协议/环保协议等 -->
        <el-col :span="24" v-if="hasFormPermission('file_url')">
          <el-form-item :label="$t('合同附件/保密协议/环保协议等')" prop="file_url">
            <xjr-custom-upload :config="file_urlConfig" :disabled="hasDisabledPermission('file_url', false)"
              v-model="formData['file_url']" list-type="text"></xjr-custom-upload>
          </el-form-item>
        </el-col>

        <el-col :span="24" v-if="hasWorkFlowFormPermission('field13465e5')" v-show="optionsFlag">
          <el-form-item :label="$t('意见簿')" prop="field13465e5">
            <xjr-opinion-comonent :value="formData.field13465e5"></xjr-opinion-comonent>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="!isWorkflowForm">
          <el-form-item size="large" v-if="isEdit">
            <el-button type="primary" @click="submitForm" :loading="submitLoading">
              {{ submitLoading ? $t('workFlow.WFMenu.hintSubmit') : $t('submit') }}</el-button>
            <el-button @click="cancelForm">{{ $t('cancelText') }}</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <!-- 请选择采购需求清单 -->
    <el-dialog append-to-body title="请选择采购需求清单" :visible.sync="approvalFormVisible" width="880px"
      :before-close="handleClose">
      <MaterialApproval ref='approval' />
      <span slot="footer" class="dialog-footer">
        <div class="height16"></div>
        <el-button @click="approvalFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="sure">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>

import FilterableDataList from '@/components/generator/clientComponents/FilterableDataList.vue';
import MaterialApproval from '../components/materialApproval.vue'
import workflowFormAuthorize from "@/mixins/workflowFormAuthorize";
import authorizeMixin from "@/mixins/authorize";
import { baseUrl } from "@/config/env";
import request from "@/router/axios";
import SelectDepartment from '@/components/staffSelector/selectDepartment.vue'
import { getUserDetailsById } from '@/api/user.js';
export default {
  mixins: [authorizeMixin, workflowFormAuthorize],

  components: { MaterialApproval,SelectDepartment },
  props: ['keyValue', 'isEdit', 'disabled'],
  data() {
    let _this = this
    return {
      submitLoading: false,
      showForm: true,
      showFormKey: 1,
      reRenderSubform: false,
      otherContractDesc: false,
      operationVal: 'add',
      isAdd: true,
      addressUrl: 'materialcontract',
      mainTableName: 'material_contract',
      formConfig: {},
      formData: {
        'field10049e8': '',
        'job': '',
        'role_id': '',
        'role_name': '',
        'area': '',
        'user_id': '',
        'apply_time': '',
        'user_name': '',
        'depart_short_name': '',
        'depart_id': '',
        'current_user_id': '',
        'is_effective': '0',
        'conctract_money': '',
        'pay_type': '',
        'other_pay_percert_desc': '',
        'material_need_list': '',
        'mateial_contract_depart_id': '',
        'use_scope': '',
        'contract_name': '',
        'contract_obj': '',
        'other_contract_desc': '',
        'contract_num': '',
        'product_name': '',
        'product_count': '',
        'product_type': '',
        'agreement_date': null,
        'devlier_date': '',
        'taunts_name': '',
        'taunts_user_id': '',
        'special_item': '',
        'scan_file_url': null,
        'file_url': null,
        'field13465e5': null,
        // 特殊条款
        details: [
          {
            content: ''
          }
        ],
        //对方联系人
        party_contact_dto:{
          party_contact_name:'',
          party_contact_mobile_num:'',
          party_contact_company:'',
          party_contact_position:'',
          party_contact_address:'',
          party_contact_email_address:'',
          party_contact_remark:'',
        },
      },
      rules: {
        job: [{
          required: true,
          message: '请输入职级名称',
          trigger: 'blur'
        }],
        role_id: [{
          required: true,
          message: '请输入角色ID',
          trigger: 'blur'
        }],
        role_name: [{
          required: true,
          message: '请输入角色名称',
          trigger: 'blur'
        }],
        area: [{
          required: true,
          message: '请输入地区',
          trigger: 'blur'
        }],
        user_id: [{
          required: true,
          message: '请输入申请人ID',
          trigger: 'blur'
        }],
        apply_time: [{
          required: true,
          message: '请输入申请时间',
          trigger: 'blur'
        }],
        user_name: [{
          required: true,
          message: '请输入申请人名称',
          trigger: 'blur'
        }],
        depart_short_name: [{
          required: true,
          message: '请输入部门简称',
          trigger: 'change'
        }],
        depart_id: [{
          required: true,
          message: '请选择部门',
          trigger: 'change'
        }],
        current_user_id: [{
          required: true,
          message: '请输入当前用户',
          trigger: 'blur'
        }],
        is_effective: [{
          required: true,
          message: '请输入是否生效',
          trigger: 'blur'
        }],
        conctract_money: [{
          required: true,
          message: '请输入合同金额',
          trigger: 'blur'
        }],
        pay_type: [{
          required: true,
          message: '请选择付款方式',
          trigger: 'change'
        }],
        other_pay_percert_desc: [{
          required: false,
          message: '请输入其他付款比例说明',
          trigger: 'blur'
        }],
        material_need_list: [{
          required: true,
          message: '请输入耗材采购需求清单',
          trigger: 'change'
        }],
        mateial_contract_depart_id: [],
        use_scope: [{
          required: true,
          message: '请选择适用范围',
          trigger: 'change'
        }],
        contract_name: [{
          required: true,
          message: '请输入合同名称',
          trigger: 'blur'
        }],
        contract_obj: [{
          required: true,
          message: '请选择合同主体',
          trigger: 'change'
        }],
        other_contract_desc: [{
          required: false,
          message: '请输入其他合同主体说明',
          trigger: 'blur'
        }],
        contract_num: [{
          required: true,
          message: '请输入合同编号',
          trigger: 'blur'
        }],
        product_name: [{
          required: true,
          message: '请输入产品名称',
          trigger: 'blur'
        }],
        product_count: [{
          required: true,
          message: '请输入产品数量',
          trigger: 'blur'
        }],
        product_type: [{
          required: true,
          message: '请输入产品型号',
          trigger: 'blur'
        }],
        agreement_date: [{
          required: true,
          message: '请选择签订日期',
          trigger: 'change'
        }],
        devlier_date: [{
          required: true,
          message: '请输入交期时间',
          trigger: 'blur'
        }],
        taunts_name: [{
          required: true,
          message: '请输入对方名称',
          trigger: 'blur'
        }],
        // taunts_user_id: [{
        //   required: true,
        //   message: '请输入对方联系人',
        //   trigger: 'blur'
        // }],
        special_item: [{
          required: false,
          message: '请输入特殊条款',
          trigger: 'blur'
        }],
        scan_file_url: [{
          required: true,
          message: '合同扫描件/word/pdf不能为空',
          trigger: 'change'
        }],
        file_url: [{
          required: true,
          message: '合同附件/保密协议/环保协议等不能为空',
          trigger: 'change'
        }],
      },
      depart_idOptions: [],
      approvalFormVisible: false,
      selectData:[],
      pay_typeOptions: [],
      mateial_contract_depart_idOptions: undefined,
      use_scopeOptions: [],
      contract_objOptions: [],
      scan_file_urlConfig: {
        "showTip": false,
        "fileSize": 2,
        "sizeUnit": "MB",
        "buttonText": "点击上传",
        "disabled": false
      },
      file_urlConfig: {
        "showTip": false,
        "fileSize": 2,
        "sizeUnit": "MB",
        "buttonText": "点击上传",
        "disabled": false
      },
      payTypeDesc: false,
      showFlag:false,
    }
  },
  computed: {},
  watch: {
    'formData.conctract_money': function (val, oldVal) {
      this.changeFormConfigDefaultValue();
    },
  },
  created() {
    this.formConfig = this.getFormConfig();
  },
  async mounted() {
    //TODO   再这里做数据回填 请求表单数据

    if (this.keyValue) {
      this.isAdd = false;
    }
    if (!this.isAdd && this.keyValue) {
      this.operationVal = 'edit';
      try {
        let res = await request({
          url: baseUrl + "/" + this.addressUrl + "/" + this.keyValue,
          method: "get",
        });
        this.formData = res.data.data

        this.showFormKey++;
      } catch (error) {
      }
    }
    if (typeof this.getPay_typeOptions == "function") {
      await this.getPay_typeOptions();
    }
    if (typeof this.getMateial_contract_depart_idOptions == "function") {
      await this.getMateial_contract_depart_idOptions();
    }
    if (typeof this.getUse_scopeOptions == "function") {
      await this.getUse_scopeOptions();
    }
    if (typeof this.getContract_objOptions == "function") {
      await this.getContract_objOptions();
    }
    // 新增获取信息表单反选
    setTimeout(() => {
      this.getCurrentInfo()
    }, 0);

  },
  methods: {
    sendDepartData(value){
      this.formData['mateial_contract_depart_id'] = value
    },
    addDetails() {
      this.formData.details.push({
        content: ''
      })
    },
    delDetails(i) {
      this.formData.details.splice(i, 1)
    },
    getCurrentInfo() {
      let params = {
        userId: this.formData['current_user_id']
      }
      getUserDetailsById(params).then(res => {
        this.formData['user_id'] = res.data.data.F_UserId//当前申请人id
        this.formData['user_name'] = res.data.data.F_RealName//当前申请人姓名
        this.formData['area'] = res.data.data.F_Area//地区
        this.formData['job'] = res.data.data.F_Job//职级
        this.departmentData = res.data.data.F_Department//部门信息
        this.roleData = res.data.data.F_Role//角色信息
        this.initRole()
      })
    },
    initRole() {
      let roleId = []
      let roleName = []
      if (this.roleData && this.roleData.length > 0) {
        this.roleData.forEach(e => {
          roleId.push(e.F_RoleId)
          roleName.push(e.F_FullName)
        })
      }
      this.formData['role_id'] = roleId.join(',')
      this.formData['role_name'] = roleName.join(',')
      this.formData['apply_time'] = this.getTime()
    },
    getTime() {
      let today = new Date()
      let year = today.getFullYear();
      let month = today.getMonth() + 1;//获取月份，值为0-11 表示1-12月份
      if (month <= 9) {
        month = "0" + month
      }
      let date = today.getDate();
      if (date <= 9) {
        date = "0" + date
      }
      let hours = today.getHours();
      if (hours <= 9) {
        hours = "0" + hours
      }
      let minutes = today.getMinutes()
      if (minutes <= 9) {
        minutes = "0" + minutes
      }
      let seconds = today.getSeconds();
      if (seconds <= 9) {
        seconds = "0" + seconds
      }
      let time = year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds
      return time
    },
    // 部门选择
    departmentChange(val) {
      this.departmentData.forEach(ele => {
        if (val == ele.F_DepartmentId) {
          this.formData['depart_short_name'] = ele.F_FullName
        }
      })
    },
    // 耗材采购审批
    selectApprovalForm() {
      this.approvalFormVisible = true
      this.$nextTick(()=>{
        this.$refs.approval.init()
      })
    },
    getFormData() {
      let key = this.mainTableName + 'Entity';
      let returnParams = {};
      returnParams[key] = this.formData;
      return {
        ...returnParams,
      };
    },
    validateForm() {
      this.$refs['elForm'].validate(valid => { });
    },
    async aysncValidateForm() {
      let validataArry = []
      validataArry.push(new Promise((resolve, reject) => {
        this.$refs['elForm'].validate(valid => {
          resolve(valid)
        })
      }))
      let res = await Promise.all(validataArry)
      if (res.includes(false)) {
        return false
      }
      else {
        return true;
      }
    },
    changeTableData() { },
    async submitForm() {
      this.submitLoading = true;
      let valid = await this.aysncValidateForm();
      if (valid == false) {
        this.submitLoading = false;
        return false;
      }
      this.changeTableData();
      //格式化数据
      let newObj = this.getFormData();

      //如果没有传入参数就是新增
      if (!this.keyValue) {

        request({
          url: baseUrl + "/" + this.addressUrl,
          method: "post",
          data: newObj
        }).then((res) => {
          this.submitLoading = false;
          this.$notify({
            title: "成功",
            message: "新增成功",
            type: "success",
          });
          this.$emit("onChange", true)
        });

      }
      else {

        request({
          url: baseUrl + "/" + this.addressUrl + "/" + this.keyValue,
          method: "put",
          data: newObj
        }).then((res) => {
          this.submitLoading = false;
          this.$notify({
            title: "成功",
            message: "修改成功",
            type: "success",
          });
          this.$emit("onChange", true)
        });

      }
    },
    Handleselect() {
      if (this.depart_idOptions && this.depart_idOptions.length > 0) {
        this.depart_idOptions.forEach(e => {
          if (e.F_DepartmentId == this.formData['depart_id']) {
            this.formData['depart_short_name'] = e.F_ShortName
          }
        })
      }
    },
    cancelForm() {
      this.$emit("onChange", true)
    },
    formatTree(data, valueField, lableField, childField, type) {
      let tree = [];
      data.forEach((node, index) => {
        let newNode = {
          value: node[valueField],
          label: node[lableField],
        };
        if (type) {
          newNode.disabled = node[valueField] == undefined ? true : false
        }
        tree.push(newNode);
        if (node[childField] != null && node[childField].length > 0) {
          newNode.children = (this.formatTree(node[childField], valueField, lableField, childField,
            type));
        }
      }, this);
      return tree;
    },

    //辅助工作流 审批(编辑) 预留方法
    handleEdit() {
    },
    convertCurrency(money) {
      //汉字的数字
      var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
      //基本单位
      var cnIntRadice = new Array('', '拾', '佰', '仟');
      //对应整数部分扩展单位
      var cnIntUnits = new Array('', '万', '亿', '兆');
      //对应小数部分单位
      var cnDecUnits = new Array('角', '分', '毫', '厘');
      //整数金额时后面跟的字符
      var cnInteger = '整';
      //整型完以后的单位
      var cnIntLast = '元';
      //最大处理的数字
      var maxNum = 999999999999999.9999;
      //金额整数部分
      var integerNum;
      //金额小数部分
      var decimalNum;
      //输出的中文金额字符串
      var chineseStr = '';
      //分离金额后用的数组，预定义
      var parts;
      // 传入的参数为空情况 
      if (money == '') return ''
      money = parseFloat(money)
      if (money >= maxNum) return ''
      // 传入的参数为0情况 
      if (money == 0) {
        chineseStr = cnNums[0] + cnIntLast + cnInteger;
        return chineseStr
      }
      // 转为字符串
      money = money.toString();
      // indexOf 检测某字符在字符串中首次出现的位置 返回索引值（从0 开始） -1 代表无
      if (money.indexOf('.') == -1) {
        integerNum = money;
        decimalNum = ''
      } else {
        parts = money.split('.');
        integerNum = parts[0];
        decimalNum = parts[1].substr(0, 4);
      }
      //转换整数部分
      if (parseInt(integerNum, 10) > 0) {
        let zeroCount = 0;
        let IntLen = integerNum.length
        for (let i = 0; i < IntLen; i++) {
          let n = integerNum.substr(i, 1);
          let p = IntLen - i - 1;
          let q = p / 4;
          let m = p % 4;
          if (n == '0') {
            zeroCount++;
          } else {
            if (zeroCount > 0) {
              chineseStr += cnNums[0]
            }
            zeroCount = 0;
            chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
          }
          if (m == 0 && zeroCount < 4) {
            chineseStr += cnIntUnits[q];
          }
        }
        // 最后+ 元
        chineseStr += cnIntLast;
      }
      // 转换小数部分
      if (decimalNum != '') {
        let decLen = decimalNum.length;
        for (let i = 0; i < decLen; i++) {
          let n = decimalNum.substr(i, 1);
          if (n != '0') {
            chineseStr += cnNums[Number(n)] + cnDecUnits[i]
          }
        }
      }
      if (chineseStr == '') {
        chineseStr += cnNums[0] + cnIntLast + cnInteger;
      } else if (decimalNum == '') {
        chineseStr += cnInteger;
      }
      return chineseStr
    },
    getNumberFixed2(number) {
      let splitNum = ("" + number).replace(/(^0*)/g, "").split(".");
      let num = splitNum[0] == "" ? '0' : splitNum[0];
      if (splitNum.length > 1) {
        num += '.';
        let roundNum = 2; //保留两位小数
        for (let i = 0; i < roundNum; i++) {
          num += splitNum[1][i];
        }
      }
      return parseFloat(num);
    },
    changeFormConfigDefaultValue() {
      let valueForFormIdMap = new Map();
      this.formConfig.fields.forEach((ele) => {
        if (ele.__config__.componentName == "table") {
          ele.__config__.children.forEach((element) => {
            valueForFormIdMap.set(ele.__config__.formId + "-table-" + element.__config__.formId,
              element.__config__.defaultValue);
          });
        }
        else if (ele.__config__.componentName && ele.__config__.componentName == 'avue-tabs') {
          let childrenObj = ele.__config__.childrenObj || {};
          let _arr = this.getValByTabs(childrenObj);
          _arr.map(item => {
            valueForFormIdMap.set(item.formId, item.defaultValue);
          });
        }
        else {
          valueForFormIdMap.set(ele.__config__.formId, this.formData[ele.__vModel__]);
        }
      });
      this.formConfig.fields.forEach((ele, index) => {
        if (ele.__config__.componentName == "table") {
          ele.__config__.children.forEach((element, childrenIndex) => {
            let defaultValue = 0;
            if (element.computationalConfiguration && element.computationalConfiguration.length > 0) {
              let formulaStr = "";
              element.computationalConfiguration.forEach((item) => {
                if (item.type == "taxRate") {
                  //税率
                  if (element.taxRate >= 0) {
                    formulaStr += element.taxRate * 0.01;
                  }
                }
                else {
                  let eleValue = valueForFormIdMap.get(item.formId) || 0;
                  formulaStr += item.formId == 0 ? item.name : eleValue;
                }
              });
              defaultValue = eval(formulaStr);
              defaultValue = this.getNumberFixed2(defaultValue);
              //大写
              if (element.isCapitalized) {
                this.formConfig.fields[index].__config__.children[childrenIndex].__config__
                  .capitalizedValue = this.getCapitalizedMethod(defaultValue);
              }
              this.formConfig.fields[index].__config__.children[childrenIndex].__config__
                .defaultValue = defaultValue;
              this.formData[element.__vModel__] = defaultValue;
            }
          });
        }
        else if (ele.__config__.componentName && ele.__config__.componentName == 'avue-tabs') {
          let childrenObj = ele.__config__.childrenObj || {};
          //avue-tabs
          this.calcDefaultValueByTabs(ele.__config__.childrenObj, valueForFormIdMap);
        }
        else {
          let defaultValue = 0;
          if (ele.computationalConfiguration && ele.computationalConfiguration.length > 0) {
            let formulaStr = "";
            ele.computationalConfiguration.forEach((item) => {
              if (item.type == "taxRate") {
                //税率
                if (ele.taxRate >= 0) {
                  formulaStr += ele.taxRate * 0.01;
                }
              }
              else {
                let eleValue = valueForFormIdMap.get(item.formId) || 0;
                formulaStr += item.formId == 0 ? item.name : eleValue;
              }
            });
            defaultValue = eval(formulaStr);
            defaultValue = this.getNumberFixed2(defaultValue);
            //大写
            if (ele.isCapitalized) {
              this.formConfig.fields[index].__config__.capitalizedValue = this.getCapitalizedMethod(
                defaultValue);
            }
            this.formConfig.fields[index].__config__.defaultValue = defaultValue;
            this.formData[ele.__vModel__] = defaultValue;
          }
        }
      });
    },
    selectContractObj() {
      if (this.formData['contract_obj'] == 4) {
        this.otherContractDesc = true
      } else {
        this.otherContractDesc = false
      }
    },
    selectPayType() {
      if (this.formData['pay_type'] == 8) {
        this.payTypeDesc = true
      } else {
        this.payTypeDesc = false
      }
    },
    getValByTabs(childrenObj) {
      let _arr = [];
      if (!childrenObj || !(childrenObj instanceof Object)) return [];
      for (let key in childrenObj) {
        let children = childrenObj[key];
        children.map(item => {
          if (item.__config__.componentName && item.__config__.componentName == 'avue-tabs') {
            let cObj = item.__config__.childrenObj || {};
            _arr.push(...this.getValByTabs(item.__config__.childrenObj));
          }
          else {
            let _obj = {};
            _obj.formId = item.__config__.formId;
            _obj.defaultValue = this.formData[item.__vModel__];
            _arr.push(_obj);
          }
        });
      }
      return (() => {
        return _arr;
      })()
    },
    calcDefaultValueByTabs(childrenObj, valueForFormIdMap) {
      if (!childrenObj || !(childrenObj instanceof Object)) return;
      for (let key in childrenObj) {
        let children = childrenObj[key];
        children.map(item => {
          if (item.__config__.componentName && item.__config__.componentName == 'avue-tabs') {
            let cObj = item.__config__.childrenObj || {};
            this.calcDefaultValueByTabs(cObj, valueForFormIdMap);
          }
          else {
            let defaultValue = 0;
            if (item.computationalConfiguration && item.computationalConfiguration.length > 0) {
              let formulaStr = "";
              item.computationalConfiguration.forEach((c) => {
                if (item.type == "taxRate") {
                  //税率
                  if (item.taxRate >= 0) {
                    formulaStr += item.taxRate * 0.01;
                  }
                }
                else {
                  let eleValue = valueForFormIdMap.get(c.formId) || 0;
                  formulaStr += c.formId == 0 ? c.name : eleValue;
                }
              });
              defaultValue = eval(formulaStr);
              defaultValue = this.getNumberFixed2(defaultValue);
              item.__config__.defaultValue = defaultValue;
              this.formData[item.__vModel__] = defaultValue;
            }
          }
        });
      }
    },
    async getPay_typeOptions() {
      // 注意：this.$axios是通过Vue.prototype.$axios = axios挂载产生的
      try {
        let resp = await this.$axios({
          method: 'get',
          url: baseUrl + '/data-items/fkfs/detail',
        });
        if (resp.data.data) {
          this.pay_typeOptions = resp.data.data;
        }
      }
      catch (error) { }
    },
    async getMateial_contract_depart_idOptions() {
      // 注意：this.$axios是通过Vue.prototype.$axios = axios挂载产生的
      try {
        let resp = await this.$axios({
          method: 'get',
          url: baseUrl + '/companies/departments/tree',
        });
        if (resp.data) {
          let {
            data
          } = resp.data
          this.mateial_contract_depart_idOptions = this.formatTree(data, 'F_DepartmentId', 'F_FullName',
            'children', 1);
        }
      }
      catch (error) { }
    },
    async getUse_scopeOptions() {
      // 注意：this.$axios是通过Vue.prototype.$axios = axios挂载产生的
      try {
        let resp = await this.$axios({
          method: 'get',
          url: baseUrl + '/data-items/hc-syfw/detail',
        });
        if (resp.data.data) {
          this.use_scopeOptions = resp.data.data;
        }
      }
      catch (error) { }
    },
    async getContract_objOptions() {
      // 注意：this.$axios是通过Vue.prototype.$axios = axios挂载产生的
      try {
        let resp = await this.$axios({
          method: 'get',
          url: baseUrl + '/data-items/hc-htzt/detail',
        });
        if (resp.data.data) {
          this.contract_objOptions = resp.data.data;
        }
      }
      catch (error) { }
    },
    //子表单权限
    getAuthorityTableChildrenList(bindTable, children) {
      let column = [];
      if (bindTable && this.formEnCodeList && this.formEnCodeList[bindTable]) {
        let formSubEnCodeList = this.formEnCodeList[bindTable];
        if (children && children.length > 0) {
          column = children.map(ele2 => {
            if (formSubEnCodeList.includes(ele2.prop)) {
              ele2.hide = false;
            }
            else {
              ele2.hide = true;
            }
            if (ele2.hide == false) {
              //工作流中系统表单必填权限
              if (this.formSubTableNotRequiredList[bindTable] != undefined) {
                if (this.formSubTableNotRequiredList[bindTable].includes(ele2.prop)) {
                  ele2.required = false;
                }
                else {
                  ele2.required = true;
                }
              }
              ele2.rules = [];
              if (ele2.required) {
                ele2.rules = ele2.ruleList;
              }
              // disabled 属性
              if (this.formSubTableDisabledList[bindTable] != undefined) {
                if (this.formSubTableDisabledList[bindTable].includes(ele2.prop)) {
                  ele2.disabled = true;
                }
                else {
                  ele2.disabled = false;
                }
              }
            }
            return ele2;
          });
        }
        return column;
      }
      else {
        return children;
      }
    },
    getFormConfig() {
      let config = {
        "fields": [{
          "__vModel__": "field10049e8",
          "__config__": {
            "label": "耗材合同审批",
            "showLabel": false,
            "titleColor": null,
            "fontSize": null,
            "tag": "h2",
            "span": 24,
            "align": "top",
            "justify": "start",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 100
          }
        }, {
          "__vModel__": "job",
          "__config__": {
            "label": "职级名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 101,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableField": "job",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "role_id",
          "__config__": {
            "label": "角色ID",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 102,
            "fieldLength": "500",
            "bindTable": "material_contract",
            "bindTableField": "role_id",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "role_name",
          "__config__": {
            "label": "角色名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 103,
            "fieldLength": "500",
            "bindTable": "material_contract",
            "bindTableField": "role_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "area",
          "__config__": {
            "label": "地区",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 104,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableField": "area",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "user_id",
          "__config__": {
            "label": "申请人ID",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 105,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableField": "user_id",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "apply_time",
          "__config__": {
            "label": "申请时间",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 106,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "apply_time",
            "bindTableFieldType": "datetime"
          }
        }, {
          "__vModel__": "user_name",
          "__config__": {
            "label": "申请人名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 107,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableField": "user_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "depart_short_name",
          "__config__": {
            "label": "部门简称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 108,
            "fieldLength": "200",
            "bindTable": "material_contract",
            "bindTableField": "depart_short_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "depart_id",
          "__config__": {
            "label": "部门",
            "showLabel": true,
            "tag": "el-select",
            "avueType": "select",
            "span": 24,
            "required": true,
            "saveField": "",
            "showField": "",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 109,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableField": "depart_id",
            "bindTableFieldType": "varchar"
          }
        },
        {
          "__vModel__": "current_user_id",
          "__type__": "info",
          "infoType": "user",
          "__organize__": true,
          "__config__": {
            "label": "当前用户",
            "showLabel": true,
            "tag": "avue-information-body",
            "avueType": "information-body",
            "defaultValue": "316231f32f1f0e5a4c56bf855806b924",
            "required": false,
            "span": 24,
            "whetherToRebindSecondaryEditing": false,
            "bindTableField": "current_user_id",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 110,
            "placeholder": "当前用户",
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableFieldType": "varchar"
          }
        },
        {
          "__vModel__": "is_effective",
          "__config__": {
            "label": "是否生效",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 111,
            "fieldLength": "1",
            "bindTable": "material_contract",
            "bindTableField": "is_effective",
            "bindTableFieldType": "int"
          }
        }, {
          "tempType": "number",
          "__vModel__": "conctract_money",
          "computationalConfiguration": [],
          "append": "元",
          "__config__": {
            "label": "合同金额",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input",
            "defaultValue": 0,
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 113,
            "fieldLength": "20",
            "bindTable": "material_contract",
            "bindTableField": "conctract_money",
            "bindTableFieldType": "double"
          }
        }, {
          "__vModel__": "pay_type",
          "__config__": {
            "label": "付款方式",
            "showLabel": true,
            "tag": "el-select",
            "avueType": "select",
            "span": 24,
            "required": true,
            "saveField": "",
            "showField": "",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 114,
            "dataType": "dataItem",
            "dataItem": "fkfs",
            "fieldLength": "10",
            "bindTable": "material_contract",
            "bindTableField": "pay_type",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "other_pay_percert_desc",
          "__config__": {
            "label": "其他付款比例说明",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 115,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "other_pay_percert_desc",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "material_need_list",
          "__config__": {
            "label": "采购需求清单",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 116,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "material_need_list",
            "bindTableFieldType": "varchar"
          }
        }, {
          "tempType": "tree",
          "__vModel__": "mateial_contract_depart_id",
          "__type__": "department",
          "__organize__": true,
          "__config__": {
            "label": "耗材合同审批部门",
            "showLabel": true,
            "required": false,
            "tag": "avue-input-tree",
            "dataKey": "data",
            "span": 24,
            "bindTableField": "mateial_contract_depart_id",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 118,
            "fieldLength": "50",
            "bindTable": "material_contract",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "use_scope",
          "__config__": {
            "label": "适用范围",
            "showLabel": true,
            "tag": "el-select",
            "avueType": "select",
            "span": 24,
            "required": true,
            "saveField": "",
            "showField": "",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 119,
            "dataType": "dataItem",
            "dataItem": "hc-syfw",
            "fieldLength": "10",
            "bindTable": "material_contract",
            "bindTableField": "use_scope",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "contract_name",
          "__config__": {
            "label": "合同名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 120,
            "fieldLength": "200",
            "bindTable": "material_contract",
            "bindTableField": "contract_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "contract_obj",
          "__config__": {
            "label": "合同主体",
            "showLabel": true,
            "tag": "el-select",
            "avueType": "select",
            "span": 24,
            "required": true,
            "saveField": "",
            "showField": "",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 121,
            "dataType": "dataItem",
            "dataItem": "hc-htzt",
            "fieldLength": "10",
            "bindTable": "material_contract",
            "bindTableField": "contract_obj",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "other_contract_desc",
          "__config__": {
            "label": "其他合同主体说明",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 135,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "other_contract_desc",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "contract_num",
          "__config__": {
            "label": "合同编号",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 122,
            "fieldLength": "200",
            "bindTable": "material_contract",
            "bindTableField": "contract_num",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "product_name",
          "__config__": {
            "label": "产品名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 123,
            "fieldLength": "100",
            "bindTable": "material_contract",
            "bindTableField": "product_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "product_count",
          "__config__": {
            "label": "产品数量",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 125,
            "fieldLength": "20",
            "bindTable": "material_contract",
            "bindTableField": "product_count",
            "bindTableFieldType": "int"
          }
        }, {
          "__vModel__": "product_type",
          "__config__": {
            "label": "产品型号",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 126,
            "fieldLength": "200",
            "bindTable": "material_contract",
            "bindTableField": "product_type",
            "bindTableFieldType": "varchar"
          }
        }, {
          "tempType": "date",
          "__vModel__": "agreement_date",
          "__config__": {
            "label": "签订日期",
            "tag": "el-date-picker",
            "avueType": "datetime",
            "defaultValue": null,
            "showLabel": true,
            "span": 24,
            "required": true,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 127,
            "fieldLength": 500,
            "bindTableFieldType": "datetime",
            "bindTable": "material_contract",
            "bindTableField": "agreement_date"
          }
        }, {
          "__vModel__": "devlier_date",
          "__config__": {
            "label": "交期时间",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 128,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "devlier_date",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "taunts_name",
          "__config__": {
            "label": "对方名称",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 129,
            "fieldLength": "200",
            "bindTable": "material_contract",
            "bindTableField": "taunts_name",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "taunts_user_id",
          "__config__": {
            "label": "对方联系人",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 130,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "taunts_user_id",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "special_item",
          "__config__": {
            "label": "特殊条款",
            "showLabel": true,
            "tag": "el-input",
            "avueType": "input-tip",
            "required": true,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 131,
            "fieldLength": 500,
            "bindTable": "material_contract",
            "bindTableField": "special_item",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "scan_file_url",
          "__config__": {
            "label": "合同扫描件/word/pdf",
            "tag": "el-upload",
            "avueType": "upload",
            "defaultValue": null,
            "showLabel": true,
            "required": true,
            "span": 24,
            "showTip": false,
            "buttonText": "点击上传",
            "fileSize": 2,
            "sizeUnit": "MB",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 132,
            "fieldLength": 2000,
            "bindTable": "material_contract",
            "bindTableField": "scan_file_url",
            "bindTableFieldType": "varchar"
          }
        }, {
          "__vModel__": "file_url",
          "__config__": {
            "label": "合同附件/保密协议/环保协议等",
            "tag": "el-upload",
            "avueType": "upload",
            "defaultValue": null,
            "showLabel": true,
            "required": true,
            "span": 24,
            "showTip": false,
            "buttonText": "点击上传",
            "fileSize": 2,
            "sizeUnit": "MB",
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 133,
            "fieldLength": 2000,
            "bindTable": "material_contract",
            "bindTableField": "file_url",
            "bindTableFieldType": "varchar"
          }
        }, {
          "tempType": "textarea",
          "__vModel__": "field13465e5",
          "__type__": "opinion",
          "__config__": {
            "label": "意见簿",
            "showLabel": true,
            "tag": "xjr-opinion-comonent",
            "defaultValue": null,
            "span": 24,
            "F_LgMarkCode": "",
            "prestrainField": "",
            "formId": 134
          }
        }]
      };
      return config;
    },
    sure(v) {
      if (v == 'del') {
        this.formData['material_need_list'] = ''
      }
      this.$refs.approval.historyTaskData = this.$refs.approval.historyTaskData.filter(e => e.isChecked)
      this.$refs.approval.myTaskData = this.$refs.approval.myTaskData.filter(e => e.isChecked)
      this.$refs.approval.manualTaskData = this.$refs.approval.manualTaskData.filter(e => e.isChecked)
      if (this.$refs.approval.historyTaskData && this.$refs.approval.historyTaskData.length > 0) {
        this.$refs.approval.historyTaskData.forEach(element => {
          this.formData['material_need_list'] += element.processInstanceId + ','
        })
      }
      if (this.$refs.approval.myTaskData && this.$refs.approval.myTaskData.length > 0) {
        this.$refs.approval.myTaskData.forEach(element => {
          this.formData['material_need_list'] += element.processInstanceId + ','
        })
      }
      if (this.$refs.approval.manualTaskData && this.$refs.approval.manualTaskData.length > 0) {
        this.$refs.approval.manualTaskData.forEach(element => {
          this.formData['material_need_list'] += element.processInstanceId + ','
        })
      }
      this.selectData = [...this.$refs.approval.historyTaskData, ...this.$refs.approval.myTaskData, ...this.$refs.approval.manualTaskData]
      this.approvalFormVisible = false
    },
    delApproval(item,index){
        if(this.$refs.approval.historyTaskData.includes(item)){
          this.$refs.approval.historyTaskData.forEach((e,i) => {
            if(e == item){
              this.$refs.approval.historyTaskData.splice(i,1)
            }
          })
        }
        if(this.$refs.approval.myTaskData.includes(item)){
          this.$refs.approval.myTaskData.forEach((e,i) => {
            if(e == item){
              this.$refs.approval.myTaskData.splice(i,1)
            }
          })
        }
        if(this.$refs.approval.manualTaskData.includes(item)){
          this.$refs.approval.manualTaskData.forEach((e,i) => {
            if(e == item){
              this.$refs.approval.manualTaskData.splice(i,1)
            }
          })
        }
        this.sure('del')
      }
  }
}

</script>
<style>
.el-table__empty-block {
  width: 100% !important;
}

.avue-form__row {
  padding: 0 !important;
}

#editorphone {
  width: 375px;
  margin: 0 auto;
  border: 1px solid #E4E7ED;
  padding: 0 7.5px;
  background: #f5f6fa;
  height: 700px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 5px;
}

#editorphone .el-col {
  border-bottom: 1px solid #F2F2F2;
  background: #fff;
  margin-bottom: 0;
  padding: 0 15px 6px !important;
  width: 100%;
}

#editorphone .el-form-item__label {
  line-height: 20px
}

#editorphone .el-input-group .el-input__inner {
  background: #f5f6fa
}

#editorphone .el-input__inner {
  border: 0
}

#editorphone .el-input-group__append,
#editorphone .el-input-group__prepend {
  border: 0;
  background: #edeef2;
  color: #666;
}

#editorphone .el-input-group .el-input__prefix {
  left: 44px
}

#editorphone .el-input-group .el-input__suffix {
  right: 44px
}

#editorphone .el-form-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-flow: wrap;
}

#editorphone .el-form-item__label {
  float: none;
  min-width: 85px;
  width: auto !important;
  text-align: left;
  flex: auto;
}

#editorphone .tinymce .el-form-item__label {
  min-width: 100%;
}

#editorphone .el-form-item__content {
  margin-left: 0px !important;
  flex: auto;
  width: calc(100% - 95px);
}

#editorphone .avueFormNoLable .el-form-item__label,
#editorphone .avueFormNoLable .avue-crud__pagination {
  display: none;
}

#editorphone .avueFormNoLable .el-collapse-item__wrap,
#editorphone .avueFormNoLable .el-collapse {
  border-bottom: 0
}

#editorphone .avueFormNoLable .el-col {
  border-bottom: 0;
  padding-bottom: 0
}

#editorphone .el-form-item__content .el-button:first-child {
  margin-left: 90px;
}

.el-upload__tip {
  line-height: 1.2;
}

.table {
  width: 100%;
}

.table-header {
  width: 100%;
  height: 40px;
  border: 1px solid #F2F2F2;
  background: #F2F2F2;
  display: flex;
  flex-direction: row;
}

.itemsss {
  width: 150px;
  height: 100%;
  border: 1px solid #999;
  text-align: center;
}

.table-body {
  width: 100%;
  height: 37px;
  border: 1px solid #F2F2F2;
  display: flex;
  flex-direction: row;
}

.payment_detail-items {
  width: 800px;
  height: 40px;
  display: flex;
  flex-direction: row;
}

.el-input-items {
  width: 600px;
}

.visibility {
  visibility: hidden;
}
</style>
